home *** CD-ROM | disk | FTP | other *** search
/ ftp.mactech.com 2010 / ftp.mactech.com.tar / ftp.mactech.com / machack / Hacks96 / BetterADsecurity.sit / Better AD security / Source / SysError.c < prev    next >
C/C++ Source or Header  |  1996-06-21  |  3KB  |  89 lines

  1. /*    NAME:
  2.         SysError.c
  3.  
  4.     WRITTEN BY:
  5.         Dair Grant,
  6.         Avi Drissman
  7.                 
  8.     DESCRIPTION:
  9.         This file contains a code resource to be installed as a Trap Patch.
  10.  
  11.     NOTES:
  12.         We are applied as a patch to SysError, and cause force-quitting to not
  13.         affect a screen saver.
  14.  
  15.     ___________________________________________________________________________
  16. */
  17. //=============================================================================
  18. //        Include files, define stuff                                                                     
  19. //-----------------------------------------------------------------------------
  20.  
  21. //#define DEBUGGING_BUILD 1
  22.  
  23. #include <Gestalt.h>
  24. #include "A4Stuff.h"
  25. #include "SetupA4.h"
  26. #include "bADs Constants.h"
  27. #include "ES Address Table.h"
  28. #include <Assembler.h>
  29. #include "AfterDarkGestalt.h"
  30.  
  31.  
  32. //=============================================================================
  33. //        Types                                                                 
  34. //-----------------------------------------------------------------------------
  35.  
  36.  
  37. //=============================================================================
  38. //        Global Variables                                                                 
  39. //-----------------------------------------------------------------------------
  40.  
  41.  
  42. //=============================================================================
  43. //        Private function prototypes                             
  44. //-----------------------------------------------------------------------------
  45. asm void    main(void);
  46.  
  47.  
  48. //=============================================================================
  49. //        main : Entry point to our code resource.                                                                 
  50. //-----------------------------------------------------------------------------
  51. //        Note :    We check to see if we should allow the force quit.
  52. //-----------------------------------------------------------------------------
  53. asm void    main(void)
  54. {
  55.     cmp.w #kForceQuit, d0                    //Force quit?
  56.     bne.s callThru                            //Never mind, then.
  57.     
  58.     movem.l a0-a5/d0-d7, -(a7)                //Save the registers
  59.     move.l #gestaltScreenSaverAttr, d0
  60.     _Gestalt
  61.     cmp.w #noErr, d0                        //Error?
  62.     beq.s isScreenSaver
  63.     movem.l (a7)+, a0-a5/d0-d7                //Pull registers
  64.     bra.s callThru
  65.  
  66. isScreenSaver:
  67.     move a0, d0                                //Damn, can't bit-test a0
  68.     btst #gestaltSaverAsleep, d0            //Are we screen saving?
  69.     bne.s areSaving
  70.     movem.l (a7)+, a0-a5/d0-d7                //Pull registers
  71.     bra.s callThru
  72.  
  73. areSaving:
  74.     movem.l (a7)+, a0-a5/d0-d7                //Pull registers
  75.     rts                                        //Cancel force-quit
  76.     
  77. callThru:
  78.     movem.l a0/a2-a5/d0-d7, -(a7)            //Save the registers
  79.     move.l #kbADsAddressTable, d0
  80.     _Gestalt                                //Where do we go?
  81.     move.l a0, a1
  82.     movem.l (a7)+, a0/a2-a5/d0-d7            //Pull registers
  83.     addq.l #8, a1
  84.     addq.l #4, a1                            //Find where to go
  85.     move.l (a1), -(sp)                        //Jump!
  86.     rts
  87.  
  88. }
  89.